import React from "react"
import Suit from "./HOC/Suit" //引入高阶组件

//其实是组件复用了高阶组件中的逻辑
//把可以复用的逻辑都放到高阶组件中
@Suit
class Lzw extends React.Component {
    constructor() {
        super()
        this.state = {
            name: '廖紫薇',
            age: 20,
            hobby: "吃喝玩写代码"
        }
    }
    render() {
        let { name, age, hobby } = this.state;
        let { color = "#000", nickname, skill, weapon, attack } = this.props;//从高阶组件中拓展的属性
        return (
            <fieldset style={{ color }}>
                <legend>Lzw</legend>
                <h1>姓名:{nickname ? nickname : name}</h1>
                <h1>年龄:{age}</h1>
                <h1>爱好:{hobby}</h1>
                <h1>技能:{skill ? skill : "啥也不是"}</h1>
                <h1>武器:{weapon ? weapon : "棒棒糖"}</h1>
                <button onClick={attack?attack:()=>{alert('捶你小胸胸拳')}}>突突突</button>
            </fieldset>
        )
    }
}

export default Lzw